using System.Xml;

namespace CSharpePro;

public class Demo
{
    public void TestPrint1()
    {
        Console.Write("请输入三个整数：");
        int x = int.Parse(Console.ReadLine());
        int y = int.Parse(Console.ReadLine());
        int z = int.Parse(Console.ReadLine());
        int temp;
        if (x > y)
        {
            temp = x;
            x = y;
            y = temp;
        }

        if (x > z)
        {
            temp = x;
            x = z;
            z = temp;
        }

        if (y > z)
        {
            temp = y;
            y = z;
            z = temp;
        }

        Console.WriteLine("三个数由小到大的顺序是：{0}, {1}, {2}",x,y,z);
    }

    public void TestPrint2()
    {
        int a;
        int b;
        int c;
        for (int i = 1; i <= 100; i++)
        {
            a = i / 100;
            b = i / 10 % 10;
            c = i % 10;
            int sum = 0;
            if (i % 7 != 0 && (a != 7 || b != 7 || c != 7))
            {
                sum = i + sum;

            }
Console.WriteLine(sum);

        }
    }

    public void TestPrint3()
    {
        for (int i = 1; i <= 9; i++)
        {
            for (int j = 1;j<=i; j++)
            {
                Console.Write($"{j}*{i} = {i*j} \t");
            }
            Console.WriteLine();
        }
    }

    public void TestPrint4()
    {
        for (int i = 2; i <= 1000; i++)
        {
            int sum = 0;
            for (int j = 1; j <=i/2; j++)
            {
                if (i % j == 0)
                {
                    sum += j;
                }
            }

            if (i == sum)
            {
                Console.WriteLine(i+" ");
            }
        }
    }

    public void TestPrint5()
    {
        Console.Write("请输入一个正整数：");
        int num = int.Parse(Console.ReadLine());
        int temp = num;
        if (num <= 0)
        {
            return;
        }
        int count = 0;
        String reverse = "";
        while (temp > 0)
        {
            int sum = temp % 10;
            reverse += sum;
            temp /= 10;
            count++;

        }
        Console.WriteLine($"{num}是{count}位数\t");
        Console.WriteLine($"逆序输出：");
    }

    public void TestPrint6()
    {
        int num = int.Parse(Console.ReadLine());
        int half=(num+1)/2;
        for (int i = 1; i <= half; i++)
        {
            for (int j = half; j>i; j--)
            {
                Console.WriteLine(" ");
            }

            for (int k = 1; k <= 2 * i - 1; k++)
            {
                Console.WriteLine("*");
            }
            Console.WriteLine();
        }

        for (int i = half; i >= 1; i--)
        {
            for (int j = half; j > i; j--)
            {
                Console.WriteLine(" ");
            }
            for (int k = 1; k <= 2 * i - 1; k++)
            {
                Console.WriteLine("*");
            }
            Console.WriteLine();
        }
    }
}